<template>
	<view>
		<view class="venueForm">
			<view>
				<view style="font-size: 33rpx;color: #444444;font-weight: 600;line-height: 45rpx;">请上传赛事图片</view>
				<view style="color: #888888;font-size: 26rpx;line-height: 70rpx;">图片宽高建议750*339px</view>
			</view>
			<view>
				<u-upload name="img" :fileList="imgList"  @afterRead="onUpload($event, 'img')"
						@delete="onDelete($event, 'img')"  :maxCount="1"
					width="208rpx" height="208rpx">
				</u-upload>
			</view>
		</view>
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>所属区域</view>
					<view class="fvalue" @click="pickerLocal.showLocal = true" >
						{{ (pickerLocal.local === '' ? '选择省/市/区' : pickerLocal.local) }}
					</view>
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>赛事名称</view>
					<input class="fvalue" v-model="eventInfo.eventName"  placeholder="输入赛事名称"  />
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>比赛类型</view>
					<view class="fvalue" >
						<picker mode="selector" :range="eventTypeList" range-key="sportName" @change="onEventTypeChange">
							<view class="fvalue" >
								{{ eventInfo.sportIdName || '选择比赛类型' }}
							</view>
						</picker>
					</view>
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>赛事等级</view>
					<view class="fvalue" >
						<picker mode="selector" :range="eventLevelList" range-key="dictValue" @change="onEventLevelChange">
							<view class="fvalue" >
								{{ eventInfo.eventLevelName || '选择赛事等级' }}
							</view>
						</picker>
					</view>
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle">地图定位</view>
					<view class="fvalue" @click="selectChoose">{{ eventInfo.point || '在地图选择定位' }}</view>
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>赛事地址</view>
					<input class="fvalue" v-model="eventInfo.location"  placeholder="输入详细赛事地址"  />
				</view>
			</view>
			
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>联系人</view>
					<input class="fvalue" v-model="eventInfo.linkman"  placeholder="输入联系人"  />
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>联系电话</view>
					<input class="fvalue" v-model="eventInfo.phone"  placeholder="输入联系电话"  />
				</view>
			</view>
		</view>
		
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="textareaTitle"><text class="required">*</text>报名的起止时间</view>
			<view class="form-row">
				<view class="ftitle"><text class="required">*</text>开始日期</view>
				<view class="fvalue" @click="entryStartTime.show = true" >{{ eventInfo.entryStartTime || '选择报名开始日期' }}</view>
			</view>
			<view class="height30"></view>
			<view class="form-row">
				<view class="ftitle"><text class="required">*</text>结束日期</view>
				<view class="fvalue" @click="entryEndTime.show = true" >{{ eventInfo.entryEndTime || '选择报名结束日期' }}</view>
			</view>
		</view>
		
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="textareaTitle"><text class="required">*</text>赛事的起止时间</view>
			<view class="form-row">
				<view class="ftitle"><text class="required">*</text>开始日期</view>
				<view class="fvalue" @click="eventStartTime.show = true" >{{ eventInfo.eventStartTime || '选择赛事开始日期' }}</view>
			</view>
			<view class="height30"></view>
			<view class="form-row">
				<view class="ftitle"><text class="required">*</text>结束日期</view>
				<view class="fvalue" @click="eventEndTime.show = true" >{{ eventInfo.eventEndTime || '选择赛事结束日期' }}</view>
			</view>
		</view>
		
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="textareaTitle"><text class="required">*</text>赛事内容</view>
			<view style="border: 1px solid #c3c3c3;">
				<textarea v-model="eventInfo.eventContent" style="width: 640rpx;padding: 20rpx;  height: 200rpx;font-size: 32rpx;" placeholder="请输入赛事内容"></textarea>
			</view>
		</view>
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>获奖名次</view>
					<input class="fvalue" v-model="eventInfo.prizeAwarded"  placeholder="输入获奖名次"  />
				</view>
			</view>
			
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle"><text class="required">*</text>举办单位</view>
					<input class="fvalue" v-model="eventInfo.eventOrganizer"  placeholder="输入举办单位"  />
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle">协办单位</view>
					<input class="fvalue" v-model="eventInfo.coOrganizer"  placeholder="输入协办单位"  />
				</view>
			</view>
			<view class="height30"></view>
			<view>
				<view class="form-row">
					<view class="ftitle">赞助单位</view>
					<input class="fvalue" v-model="eventInfo.investor"  placeholder="输入赞助单位"  />
				</view>
			</view>
		</view>
<!-- 		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="describe" style="font-size: 30rpx;line-height: 40rpx;">
				<view class="title" style="font-size: 33rpx;color: #444444;font-weight: 600;line-height: 45rpx;">状态：</view>
			</view>
			<view style="padding-top: 20rpx;">
				<u-radio-group v-model="eventInfo.status" placement="row" activeColor="#06ADAB">
					<u-radio size="35rpx" name="1" label="启用" labelSize="33rpx"></u-radio>
					<u-radio size="35rpx" name="0" label="禁用" :customStyle="{marginLeft: '30rpx'}" labelSize="33rpx"></u-radio>
				</u-radio-group>
			</view>
		</view> -->
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="describe" style="font-size: 30rpx;line-height: 40rpx;">
				<view class="title" style="font-size: 33rpx;color: #444444;font-weight: 600;line-height: 45rpx;">提交报告：</view>
				<view>报名是否上传提交报告。</view>
			</view>
			<view style="padding-top: 20rpx;">
				<u-radio-group v-model="eventInfo.eventPhysical" placement="row" activeColor="#06ADAB">
					<u-radio size="35rpx" name="1" label="需要" labelSize="33rpx"></u-radio>
					<u-radio size="35rpx" name="0" label="不需要" :customStyle="{marginLeft: '30rpx'}" labelSize="33rpx"></u-radio>
				</u-radio-group>
			</view>
		</view>
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="describe" style="font-size: 30rpx;line-height: 40rpx;">
				<view class="title" style="font-size: 33rpx;color: #444444;font-weight: 600;line-height: 45rpx;">是否支援外援：</view>
			</view>
			<view style="padding-top: 20rpx;">
				<u-radio-group v-model="eventInfo.isForeignAid" placement="row" activeColor="#06ADAB">
					<u-radio size="35rpx" name="1" label="是" labelSize="33rpx"></u-radio>
					<u-radio size="35rpx" name="0" label="否" :customStyle="{marginLeft: '30rpx'}" labelSize="33rpx"></u-radio>
				</u-radio-group>
			</view>
			<view class="height30"></view>
			<view v-if="eventInfo.isForeignAid == '1'">
				<view class="form-row">
					<view class="ftitle">外援人数</view>
					<input class="fvalue" type="number" v-model="eventInfo.foreignAidCount"  placeholder="输入获奖名次"  />
				</view>
			</view>
		</view>
		
		<view class="height30 bg-f1f1f1"></view>
		<view class="venueForm">
			<view class="textareaTitle">注意事项</view>
			<view style="border: 1px solid #c3c3c3;">
				<textarea v-model="eventInfo.note" style="width: 640rpx;padding: 20rpx;  height: 200rpx;font-size: 32rpx;" placeholder="请输入注意事项"></textarea>
			</view>
		</view>
		
		<view style="padding-top: 30rpx;position: sticky;bottom: 0px;z-index: 10;background-color: #ffffff;">
			<view style="padding: 20rpx 40rpx;">
				<u-button text="保存赛事" @click="submitNenueLocationApply" color="#155CCF"></u-button>
			</view>
		</view>
		
		
		<!-- 报名开始日期 -->
		<u-datetime-picker
				:show="entryStartTime.show"
				v-model="entryStartTime.value"
				mode="datetime"
				@confirm="entryStartTimeConfirm"
				@cancel = "entryStartTime.show = false"
		></u-datetime-picker>
		<!-- 报名结束日期 -->
		<u-datetime-picker
				:show="entryEndTime.show"
				v-model="entryEndTime.value"
				mode="datetime"
				@confirm="entryEndTimeConfirm"
				@cancel = "entryEndTime.show = false"
		></u-datetime-picker>
		
		<!-- 赛事开始日期 -->
		<u-datetime-picker
				:show="eventStartTime.show"
				v-model="eventStartTime.value"
				mode="datetime"
				@confirm="eventStartTimeConfirm"
				@cancel = "eventStartTime.show = false"
		></u-datetime-picker>
		<!-- 赛事结束日期 -->
		<u-datetime-picker
				:show="eventEndTime.show"
				v-model="eventEndTime.value"
				mode="datetime"
				@confirm="eventEndTimeConfirm"
				@cancel = "eventEndTime.show = false"
		></u-datetime-picker>
		
		<!-- 省市区控件 -->
		<u-picker
		     @cancel="pickerLocal.showLocal = false"
		     @close="pickerLocal.showLocal = false"
		     :show="pickerLocal.showLocal"
		     :columns="pickerLocal.addressColumns"
		     @confirm="localConfirm"
		     title="请选择所属区域"
		     keyName="name"
		     itemHeight="80"
		     closeOnClickOverlay
		     ref="uPicker"
		     @change="changeHandler"
		     :defaultIndex="pickerLocal.defaultAddress"
		     immediateChange
		   ></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//行政区划选择
				pickerLocal:{
					//区域
					local: '',
					//展示弹出层
					showLocal: false,
					//数据数组
					addressColumns: [],
					//默认选中
					defaultAddress: [],
					//原始数据
					addressData: []
				},
				//赛事ID，用来辨别是否编辑
				eventId: '',
				//赛事首页图片
				imgList: [],
				//提交表单
				eventInfo: {
					//发布类型 0、官方；1、场馆；2、学校 ；3、公园
					publishType: '',
					refId: '',
					//赛事名称
					eventName: '',
					//赛事图片
					img: '',
					//比赛类型
					sportId: '',
					//比赛类型名称
					sportIdName: '',
					//赛事等级
					eventLevel: '',
					//赛事等级名称
					eventLevelName: '',
					//赛事地址
					location: '',
					//经度
					lng: '',
					//纬度
					lat: '',
					//联系人
					linkman: '',
					//联系电话
					phone: '',
					//赛事内容（赛事简介）
					eventContent: '',
					//联系电话
					prizeAwarded: '',
					//报名开始时间
					entryStartTime: '',
					//报名结束时间
					entryEndTime: '',
					//赛事开始时间
					eventStartTime: '',
					//赛事结束时间
					eventEndTime: '',
					//赛事举办方
					eventOrganizer: '',
					//协办方
					coOrganizer: '',
					//投资方
					investor: '',
					//完成状态
					status: '0',
					//赛事体检状态：0.不需要，1.需要
					eventPhysical: '0',
					//是否支持外援（0 否 1 是）
					isForeignAid: '0',
					//外援数量
					foreignAidCount: 0,
					//注意事项
					note: ''
				},
				//报名开始日期
				entryStartTime:{
					show: false,
					value: '',
				},
				//报名结束日期
				entryEndTime:{
					show: false,
					value: '',
				},
				//赛事开始日期
				eventStartTime:{
					show: false,
					value: '',
				},
				//赛事结束日期
				eventEndTime:{
					show: false,
					value: '',
				},
				//赛事类型数据集合
				eventTypeList: [],
				//赛事等级数据集合
				eventLevelList: [],
			}
		},
		onUnload(){
			//地理位置，销毁地理位置监听
			uni.$off("callLocationAddr");
		},
		onLoad(option) {
			//赛事ID
			var eventId = option.eventId;
			this.eventId = eventId;
			var identity = uni.getStorageSync('identity');
			if( identity == 2 ){
				//场馆主
				this.eventInfo.publishType = 1;
				//场馆ID
				this.eventInfo.refId = uni.getStorageSync('venueId');
			} else {
				uni.showModal({
				   title: '提示',
				   content: '您的角色不允许您添加赛事',
				   showCancel: false,
				   success: function (res) {
						uni.navigateBack()
				   }
				});
			}
			//地理位置监听回调
			uni.$on("callLocationAddr",(obj) => {
				this.eventInfo.location = obj.address;
				this.eventInfo.lat = obj.latitude;
				this.eventInfo.lng = obj.longitude;
			});
			//初始化同步调用
			this.initData();
		},
		methods: {
			//初始化加载
			async initData(){
				if(this.eventId ){
					await this.eventDetail();
				}
				//赛事类型
				await this.eventTypeDict();
				//赛事等级
				await this.eventLevelDict();
				//赛事省市区地址 
				await this.fetchAddressList();
			},
			//赛事详情
			eventDetail(){
				return new Promise((resolve, reject) => {
					this.$request({
						url: '/blade-merchant-app/merchant-app/event/detail',
						type: 'GET',
						data: {'id': this.eventId}
					}).then(res => {
						uni.hideLoading();
						var eventData = res.data;
						this.eventInfo = {
							//发布类型 0、官方；1、场馆；2、学校 ；3、公园
							publishType: eventData.publishType,
							refId: eventData.refId,
							//赛事名称
							eventName: eventData.eventName,
							//赛事图片
							img: eventData.img,
							//比赛类型
							sportId: eventData.sportId,
							//比赛类型名称
							sportIdName: eventData.sportIdName,
							//赛事等级
							eventLevel: eventData.eventLevel,
							//赛事等级名称
							eventLevelName: eventData.eventLevelName,
							//赛事地址
							location: eventData.location,
							//经度
							lng: eventData.lng,
							//纬度
							lat: eventData.lat,
							//联系人
							linkman: eventData.linkman,
							//联系电话
							phone: eventData.phone,
							//赛事内容（赛事简介）
							eventContent: eventData.eventContent,
							//联系电话
							prizeAwarded: eventData.prizeAwarded,
							
							//报名开始时间
							entryStartTime: eventData.entryStartTime,
							//报名结束时间
							entryEndTime: eventData.entryEndTime,
							
							//赛事开始时间
							eventStartTime: eventData.eventStartTime,
							//赛事结束时间
							eventEndTime: eventData.eventEndTime,
							//赛事举办方
							eventOrganizer: eventData.eventOrganizer,
							//协办方
							coOrganizer: eventData.coOrganizer,
							//投资方
							investor: eventData.investor,
							//完成状态
							status: eventData.status.toString(),
							//赛事体检状态：0.不需要，1.需要
							eventPhysical: eventData.eventPhysical.toString(),
							//是否支持外援（0 否 1 是）
							isForeignAid: eventData.isForeignAid.toString(),
							//外援数量
							foreignAidCount: eventData.foreignAidCount,
							//注意事项
							note: eventData.note,
						};
						this.imgList.push({ url: eventData.img });
						resolve(eventData); 
					}).catch(err =>{
						reject(err); 
					})
				})
			},
			//比赛类型字典
			eventTypeDict(){
				return new Promise((resolve, reject) => {
					this.$request({
						url: '/blade-business/blade-sportype/sportype/page',
						type: 'GET',
						data: {}
					}).then(res => {
						this.eventTypeList = res.data.records;
						if(this.eventInfo.sportId){
							var sportIdObject = res.data.records.find(item => {
								return this.eventInfo.sportId == item.id;
							});
							if(sportIdObject){
								this.eventInfo.sportIdName = sportIdObject.sportName;
							}
						}
						resolve(res.data);
					}).catch(err =>{
						reject(err); 
					})
				});
			},
			//赛事等级字典
			eventLevelDict(){
				return new Promise((resolve, reject) => {
					this.$request({
						url: '/blade-client-business/app/dict/getDictList',
						type: 'GET',
						data: {'code': 'event_level'}
					}).then(res => {
						this.eventLevelList = res.data;
						if(this.eventInfo.eventLevel){
							var eventLevelObject = res.data.find(item => {
								return this.eventInfo.eventLevel == item.dictKey;
							});
							if(eventLevelObject){
								this.eventInfo.eventLevelName = eventLevelObject.dictValue;
							}
						}
						resolve(res.data); // 操作成功，处理结果
					}).catch(err =>{
						reject(err); 
					})
				});
			},
			// 报名开始日期确认
			entryStartTimeConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				var entryStartTime = timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
				this.eventInfo.entryStartTime = entryStartTime;
				this.entryStartTime.show = false;
			},
			// 报名结束日期确认
			entryEndTimeConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				var entryEndTime = timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
				this.eventInfo.entryEndTime = entryEndTime;
				this.entryEndTime.show = false;
			},
			// 赛事开始日期确认
			eventStartTimeConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				var eventStartTime = timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
				this.eventInfo.eventStartTime = eventStartTime;
				this.eventStartTime.show = false;
			},
			// 赛事结束日期确认
			eventEndTimeConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				var eventEndTime = timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
				this.eventInfo.eventEndTime = eventEndTime;
				this.eventEndTime.show = false;
			},
			
			//比赛类型改变事件
			onEventTypeChange(event) {
				const selectedIndex = event.detail.value; // 获取用户选择的选项索引
				const selectedOption = this.eventTypeList[selectedIndex]; // 获取用户选择的选项信息
				this.eventInfo.sportIdName = selectedOption.sportName;
				this.eventInfo.sportId = selectedOption.id;
			},
			//比赛类型改变事件
			onEventLevelChange(event) {
				const selectedIndex = event.detail.value; // 获取用户选择的选项索引
				const selectedOption = this.eventLevelList[selectedIndex]; // 获取用户选择的选项信息
				this.eventInfo.eventLevelName = selectedOption.dictValue;
				this.eventInfo.eventLevel = selectedOption.dictKey;
			},
			
			//下一步保存按钮事件
			submitNenueLocationApply(){
				if(this.imgList.length<=0){
					uni.$u.toast("请上传赛事图片")
					return ;
				}
				if(!this.eventInfo.eventName){
					uni.$u.toast("请输入赛事名称")
					return ;
				}
				if(!this.eventInfo.sportId){
					uni.$u.toast("请选择比赛类型")
					return ;
				}
				if(!this.eventInfo.eventLevel){
					uni.$u.toast("请选择赛事等级")
					return ;
				}
				if(!this.eventInfo.location){
					uni.$u.toast("请输入赛事地址")
					return ;
				}
				if(!this.eventInfo.linkman){
					uni.$u.toast("请输入联系人")
					return ;
				}
				if(!this.eventInfo.phone){
					uni.$u.toast("请输入联系电话")
					return ;
				}
				if(!this.eventInfo.eventContent){
					uni.$u.toast("请输入赛事内容")
					return ;
				}
				if(!this.eventInfo.prizeAwarded){
					uni.$u.toast("请输入获奖名次")
					return ;
				}
				
				if(!this.eventInfo.entryStartTime){
					uni.$u.toast("请选择报名开始日期")
					return ;
				}
				if(!this.eventInfo.entryStartTime){
					uni.$u.toast("请选择报名开始时间")
					return ;
				}
				if(!this.eventInfo.entryEndTime){
					uni.$u.toast("请选择报名结束日期")
					return ;
				}
				if(!this.eventInfo.entryEndTime){
					uni.$u.toast("请选择报名结束时间")
					return ;
				}
				
				if(!this.eventInfo.eventStartTime){
					uni.$u.toast("请选择赛事开始日期")
					return ;
				}
				if(!this.eventInfo.eventStartTime){
					uni.$u.toast("请选择赛事开始时间")
					return ;
				}
				if(!this.eventInfo.eventEndTime){
					uni.$u.toast("请选择赛事结束日期")
					return ;
				}
				if(!this.eventInfo.eventEndTime){
					uni.$u.toast("请选择赛事结束时间")
					return ;
				}
				
				if(!this.eventInfo.eventOrganizer){
					uni.$u.toast("请输入举办单位")
					return ;
				}
				let that=this
				uni.showModal({
					title: '提示',
					content: '确认保存赛事?',
					success: function(res) {
						if (res.confirm) {
							that.saveOrUpdate();
						}
					}
				});
			},
			//提交保存
			saveOrUpdate(){
				const params = {
					...this.eventInfo
				};
				
				params.img = this.imgList.map(item => item.url).join(',');
				
				uni.showLoading({
					title: '保存中',
					mask: true
				})
				var saveUrl = '/blade-merchant-app/merchant-app/event/save';
				if(this.eventId){
					saveUrl = '/blade-merchant-app/merchant-app/event/update';
					params.id =  this.eventId;
				}
				
				
				this.$request({
					url: saveUrl,
					type: 'POST',
					data: params
				}).then(res => {
					uni.hideLoading();
					if(res.code == 200){
						uni.showModal({
						   title: '保存成功',
						   content: '可以在赛事管理对发布赛事进行管理',
						   showCancel: false,
						   success: function (res) {
							   if (res.confirm) {
								    uni.navigateBack()
							   }
						   }
						});
					} else {
						uni.showModal({
						   title: '发布失败',
						   content: res.msg,
						   showCancel: false,
						   success: function (res) {}
						});
					}
				}).catch(err =>{
					
				})
			},
			// 上传文件
			onUpload(files, type) {
				const {
					file
				} = files;
				let index = this[`${type}List`].length;
				this[`${type}List`].push({
					...file,
					status: 'uploading',
					message: '上传中'
				})
				this.$utils.onUploadFile(file.url)
					.then(res => {
						let item = this[`${type}List`][index];
						this[`${type}List`].splice(index, 1, Object.assign(item, {
							status: 'success',
							message: '',
							url: res.data.link
						}))
					})
			},
			// 删除图片
			onDelete(e, type) {
				this[`${type}List`].splice(e.index, 1);
			},
			//获取地址
			fetchAddressList() {
				var that = this;
				return new Promise((resolve, reject) => {
					this.$request({
						url: '/blade-client-business/app/organization/list',
						data: {}
					}).then(res => {
						if (res?.code === 200) {
							const {
								data
							} = res;
							var addressData = data[0];
							that.pickerLocal.addressData = [addressData];
							// this.pickerLocal.local = addressData.deptName+"-"+addressData.children[0].deptName+"-"+addressData.children[0].children[0].deptName;
							that.addressPickData();
						}
						resolve(res.data); // 操作成功，处理结果
					}).catch(err =>{
						reject(err); 
					})
				});
			},
			addressPickData(){
				//省的数组
				const provinceData = this.pickerLocal.addressData.map(e => {
					return { name: e.deptName, code: e.id }//这里可以直接return e.name  这里我是要用到code所以才用对象包起来的 下面的市 区 也一样
				})
				//市的数组
				const cityData = this.pickerLocal.addressData.map(e => {
					const arr = []
					arr.push(
					  e.children.map(c => {
						return { name: c.deptName, code: c.id }
						  
					  })
					)
					return arr
				})
				//区的数组
				const areaData = this.pickerLocal.addressData.map(e => {
					const arr = []
					arr.push(
					  e.children.map(c =>
						c.children.map(d => {
						  return { name: d.deptName, code: d.id }
						})
					  )
					)
					return arr
				})
				const arr = [provinceData, cityData[0][0], areaData[0][0][0]]
				this.pickerLocal.addressColumns = arr    //将得到的3个数组 的第一个市的所有数据赋值 作为初始数据
				 
			},
			changeHandler(e) {
				//分别表示选中的列 , 该列的第几个,选中的3列的第几个的数组,组件本身
				const { columnIndex, index, indexs, picker = this.$refs.uPicker } = e
			   //如果改变的是第一列
				if (columnIndex === 0) {
				  const children1 = this.pickerLocal.addressData[index].children.map(e => {
					return { name: e.deptName, code: e.id }
				  })
				  picker.setColumnValues(1, children1)
				//更换 第二列数据
				  const children2 = this.pickerLocal.addressData[index].children[indexs[1]].children.map(e => {
					return { name: e.deptName, code: e.id }
				  })
				  picker.setColumnValues(2, children2)
				//更换 第三列数据
				}
				if (columnIndex === 1) {
					//如果改变的是第二列
				  const children3 = this.pickerLocal.addressData[indexs[0]].children[indexs[1]].children.map(e => {
					return { name: e.deptName, code: e.id }
				  })
				  picker.setColumnValues(2, children3)
					//更换 第三列数据
				}
			},
			localConfirm(e) {
				//显而易见 不多赘述
				this.pickerLocal.local = `${e.value[0].name}-${e.value[1].name}-${e.value[2].name}`
				//获取最后一级
				this.eventInfo.org =  `${e.value[2].code}`;
				//关闭选择的窗口
				this.pickerLocal.showLocal = false
			},
			//选择地址获取经纬度
			selectChoose() {
				var url = '/pagesWorkbenches/pages/amap-choose';
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f1f1f1;
		
		.bg-f1f1f1 {
			background: #f1f1f1;
		}
		
		.height30 {
			height: 30rpx;
		}
		
		.venueForm {
			padding: 40rpx;
			background-color: #ffffff;
			
			.textareaTitle {
				padding-bottom: 20rpx;font-size: 33rpx;color: #444444;font-weight: 600;line-height: 45rpx;
				
				.required {
					color: red;
				}
			}
			
			.form-row {
				border-radius: 0rpx;display: flex;border: 1px solid #c3c3c3;justify-content: center;align-items: center; 
				
				.ftitle {
					text-align: center;
					font-size: 30rpx;
					width: 180rpx;
					display: inline-table;
					color: #333333;
					padding:0rpx 10rpx;
					
					.required {
						color: red;
					}
				}
				.fvalue {
					height: 90rpx;width: 100%;font-size: 32rpx;line-height: 90rpx;overflow: hidden;
				}
			
			}
			
			
			.submitBtn {
				height: 90rpx;background-color: #0544ab;color: #ffffff;line-height: 90rpx;font-size: 32rpx;
			}
			
		}
		
	}

</style>
